﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Autofac;//引包

namespace FineAdmin.Web.CommonService
{
    public class ServiceLocator
    {
        private static IContainer _container;

        /// <summary>
        /// 设置Ico容器
        /// </summary>
        /// <param name="container"></param>
        public static void SetContainer(IContainer container)
        {
            _container = container;
        }

        /// <summary>
        /// 获取服务
        /// </summary>
        /// <typeparam name="IService"></typeparam>
        /// <returns></returns>
        public static IService GetService<IService>()
        {
            return _container.Resolve<IService>();
        }

        /// <summary>
        /// 获取容器对象
        /// </summary>
        /// <returns></returns>
        public static IContainer GetContainer()
        {
            return _container;
        }
    }
}